/**
 * @class 进场控制器
 * @author DuskyHuang 圣子
 * @description 目前没有什么功能，主要决定是否弹出引导。
*/

import { profiler, _decorator, } from 'cc';
import { core, Mediator } from 'cfw';
import { Res } from 'const';
import { UI } from 'notifications';
import { ui, user } from 'proxies';
const { ccclass, property } = _decorator;

@ccclass('cocosmos.enter-controller')
export class EnterController extends Mediator {

    @property public useGuide: boolean = true;

    protected start() {
        profiler.hideStats();
        this._playBgm();
        this._localize();
        if (this.useGuide) this._tryGuide();
    }

    private _tryGuide(): void {
        if (!user.guided) {
            this.notify(UI.Panels.OPEN, Res.Prefabs.GUIDE_PANEL);
        }
    }

    private _playBgm(): void {
        core.audio.bgmVolume = user.guided ? 0.5 : 0.25;
        core.audio.playBgm();
    }

    private _localize(): void {
        if (user.language) ui.localizeLanguage(user.language);
    }

}